home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / texsis / old / TXSpatch.15g < prev   
Text File  |  1993-04-18  |  11KB  |  220 lines

  1. %% file: TXSpatch.tex                                    TeXsis 2.15/f
  2. %  $Revision: 16.7 $  :  $Date: 1993/04/20 16:59:22 $  :  $Author: myers $
  3. %======================================================================*
  4. % The file TXSpatch.tex is read in by texsis at run time, if it
  5. % exists.  These patches correct minor problems which will be fixed
  6. % in the next release of TeXsis.  
  7.  
  8. %%\def\revdate{13 August 1992}\def\fmtversion{2.15/c}%
  9. %%\def\revdate{29 September 1992}\def\fmtversion{2.15/d}%
  10. %%\def\revdate{10 October 1992}\def\fmtversion{2.15/e}%
  11. %%\def\revdate{12 October 1992}\def\fmtversion{2.15/f}%
  12. \def\revdate{20 November 1992}\def\fmtversion{2.15/g}%
  13.  
  14. \ATunlock       % make @ a letter for "hidden" macro names
  15.  
  16. %==================================================*
  17. % Patch a:  Reference citations and numbering
  18. %
  19. % In citations to equation numbers which have letters in them the
  20. % letters should be in (math) italics, just as in the original equation
  21. % number.  Thus the citation macros should put \use in math quotes.  
  22.  
  23. \def\Eq#1{Eq.~($\use{Eq.#1}$)}          % \Eq  prints  "Eq. (nn)"
  24. \def\Eqs#1{Eqs.~($\use{Eq.#1}$)}        % \Eqs prints  "Eqs. (nn)"
  25. \def\Ep#1{($\use{Eq.#1}$)}              % \Ep  prints just "(nn)"
  26.  
  27.  
  28. % Also, \frac got changed, so change it back to what it used to be
  29.  
  30. \def\frac#1#2{{#1\over #2}}
  31.  
  32.  
  33. % Not a bug patch, but a nice improvement.  The following code
  34. % causes \ListReferences to reset everything so that you can
  35. % continue collecting references.  The counters are reset to zero
  36. % and \refint is re-initialized so that it will re-open the .ref file.
  37. % [Thanks to Betty A for suggesting this.  It will be a part of the
  38. % next release.]
  39.  
  40. % \refReset resets the counters so that more references can be created
  41. % after \ListReferences has been called.  For example, if you listed the
  42. % references for one chapter and want to begin collecting references for
  43. % the next chapter. 
  44.  
  45. \def\refReset{% reset reference/citation counters
  46.    \global\refnum=\z@                           % counter for reference numbers
  47.    \global\@firstrefnum=1                       % first of a series of refs
  48.    \global\@lastrefnum=1                        % last of a series of refs
  49.    \global\@BadRefs=0                           % count undefined references
  50.    \gdef\refinit{\@refinit}%                    % re-enable \refinit
  51.    }
  52.  
  53. % need to change \refinit so it can be turned on again later, if
  54. % need be.
  55.  
  56. \def\@refinit{\ifrefswitch               % is .ref ouput enabled?
  57.    \immediate\openout\reflistout=\jobname.ref  % y: open .ref file for output
  58.   \else                                 % no:
  59.     \let\@refwrite=\@refwrong           %   disable output
  60.     \let\@refNXwrite=\@refwrong         %   disable output
  61.     \immediate\closeout\reflistout      % and make sure output closed
  62.   \fi                                   %
  63.   \gdef\refinit{\relax}%                % disable \refinit once it's done
  64. }%
  65.  
  66. \def\refinit{\@refinit}                 % start with \refinit enabled
  67.  
  68. %==================================================*
  69. % Patch b:  fix \EQNdisplaylines
  70. %
  71. % previous version of \EQNdisplaylines did not work like \displaylines
  72. % when it came to left justifying equations with \hfill. This one does.  
  73.  
  74. \def\EQNdisplaylines#1{%                % make \EQN re-\def local
  75.    \@EQNcr                              % change \def of \EQN to get label
  76.    \displ@y                             % reduce interline spacing (from Plain)
  77.    \halign{%                            % alignment
  78.       \hbox to\displaywidth{%           % full width
  79.       $\@lign\hfil\displaystyle##\hfil$}% centered displaystyle
  80.       &\llap{$\@lign\@@EQN{##}$}\crcr   % then eqn number template
  81.    #1\crcr}%                            % now apply template to argument
  82.    \@EQNuncr}                           % put \EQN back to normal
  83.  
  84.  
  85. %==================================================*
  86. % Patch c: fix the problem with \@eatpar eating \def's 
  87. %
  88. % \@eatpar gets rid of any \par that follows.  We have to use \futurelet
  89. % to avoid problems when what follows is a \def or somesuch.
  90.      
  91. \def\@eatpar{\futurelet\next\@testpar}
  92. \def\@testpar{\ifx\next\par\let\@next=\@@eatpar\else\let\@next=\relax\fi\@next}
  93. \long\def\@@eatpar#1{\relax}
  94.  
  95. %==================================================*
  96. % patch d:  \loadstyle fails on PC-TeX and NorthLake TeX, so..
  97. %
  98. % Previously \loadstyle used \openin to try to determine if the style
  99. % file to load existed.  If it could not be opened then \ifeof would be
  100. % true.  However, some implementations of TeX do not look through the
  101. % whole TEXINPUTS path for \openin (as they do for \input) so this is
  102. % not a reliable test.  We consider this a bug, but we have to live with
  103. % it until those guys get their TeX fixed!  So now we just use \input to
  104. % read the style file.  But if \openin can't find the file we at least
  105. % say what we are trying to do, in case it does fail.  
  106.  
  107. \newread\txsfile                % to help look for style files
  108.  
  109. \def\loadstyle#1#2{%            % load a definition for #1 from file #2
  110.    \def#1{\@loaderr{#1}}%       % disable #1 (just in case...)
  111.    \ATunlock                    % make @ a letter, in case it's in the file
  112.    \immediate\openin\txsfile=#2 % try to open the file to see if it exists
  113.    \ifeof\txsfile               % if end of file, then print a message
  114.       \emsg{> Trying to load the style file #2...}% before trying to \input
  115.    \fi                          %
  116.    \closein\txsfile             % just close the file in any case
  117.    \input #2 \relax             % load (or try to) the file with the new \def
  118.    \ATlock                      % @ now no longer a letter
  119.    #1}                          % now use the new definitions
  120.  
  121.  
  122. % Slight problem with \Listing:  The ``~'' character was not made a
  123. % normal character.  This patch makes it so.
  124.  
  125. \def\Listing{\beginEnv{Listing}%                %
  126.    \vskip\EnvDelt@skip                          % do extra skip
  127.    \baselineskip=\normalbaselineskip            % singlespaced
  128.    \obeylines                                   % respect line endings
  129.    \parskip=\z@ \parindent=\z@                  % set \par indentation to zero
  130.    \obeyspaces\tt                               % and obey spaces too
  131.    \def\\##1{\char92##1}%                       % \ for macro names
  132.    \catcode`\{=\other \catcode`\}=\other        % { and } just characters
  133.    \catcode`\(=\other \catcode`\)=\other        % ( and ) just characters
  134.    \catcode`\"=\other \catcode`\|=\other        % " and | just characters
  135.    \catcode`\%=\other \catcode`\&=\other        % so %  and & are characters
  136.    \catcode`\-=\other \catcode`\==\other        % so -  and = are characters
  137.    \catcode`\$=\other \catcode`\#=\other        % so $  and # are characters
  138.    \catcode`\_=\other \catcode`\^=\other        % so _  and ^ are characters
  139.    \catcode`\~=\other                           % ~ is not active tie!
  140.    }                                            %
  141.  
  142. %==================================================*
  143. % patch e: \@BadTags and \@BadRefs should use \global\advance
  144. %
  145. % in TXStags.tex:
  146.  
  147. \def\@use#1{%   does the work for \use
  148.    \endgroup                                    % end unspecial characters
  149.    \stripblanks @#1@\endlist                    % @name@ -> \tok w/o blanks
  150.    \XA\ifx\csname\tok\endcsname\relax\relax     % is \@name@ undefined?
  151.      \emsg{> UNDEFINED TAG #1 ON PAGE \folio.}% % yes: error message
  152.      \global\advance\@BadTags by 1              % count how many
  153.      \@errmark{UNDEF}%                          %   and mark in output
  154.      \edef\tok{{\bf\tok}}%                      % and return \bf ``name''
  155.    \else                                        % else:
  156.      \edef\tok{\csname\tok\endcsname}%          %  get the definition
  157.    \fi                                          %
  158.    \tok}                                        % evaluate it
  159.  
  160.  
  161. % in TXSrefs.tex:
  162.  
  163. \def\make@refmark#1{% make a reference mark
  164.   \testtag{Ref.#1}\ifundefined           % is it undefined? (tag -> \tok)
  165.     \emsg{> UNDEFINED REFERENCE #1 ON PAGE \number\pageno.}% error message
  166.     \global\advance\@BadRefs by 1        % count undefined references
  167.     \xdef\@refmark{{\tenbf #1}}%         % cite with label in boldface
  168.     \@errmark{REF?}%                     % and mark error in output
  169.   \else                                  % no:
  170.     \xdef\@refmark{\csname\tok\endcsname}%  cite with number
  171.   \fi}                                   % end of \ifundefined
  172.  
  173.  
  174. %==================================================*
  175. % patch f:  TXSfigs.tex
  176. %
  177. % \infiglist and \intablelist were getting page numbers wrong
  178. % when many figures were inserted.  The problem was the page number
  179. % (\folio) was being evaluated when the macro was called, not when the
  180. % \write to the file was actually being performed.  Inserting one
  181. % \noexpand solves the problem.
  182.  
  183.  
  184. \def\@infiglist#1#2{% write to list of figures or tables
  185.    \FigListWrite#1{\@comment}%                  % comment '%'
  186.    \FigListWrite#1{\@comment \CaptionName\space\@ID:}% comment '%'
  187.    \FigListWrite#1{\NX\NX\NX\FIGLitem{\CaptionName} {\@ID.\space}}% 
  188.    \FigListWriteNX#1{{#2}}%      the caption text should not be expanded at all!
  189.    \FigListWrite#1{{\NX\folio}}% the page number, so don't expand until written
  190.    \endgroup}                                   % end \obeylines
  191.  
  192. %==================================================*
  193. % patch g:  TXSrefs.tex
  194. %
  195. % Use en dash in \refrange rather than hyphen. (Betty A)
  196.  
  197. \long\def\refrange#1#2#3{% cites a range of references
  198.   \reffollowsfalse                      % assume no ref. follows
  199.   \ifx#3\cite\reffollowstrue\fi         % is next token another \cite?
  200.   \ifx#3\ref\reffollowstrue\fi          % (or \ref, OLD TeXsis)
  201.   \ifx#3\reference\reffollowstrue\fi % or is it \reference? then set
  202. flag.
  203.   \ifx#3\refrange\reffollowstrue\fi     % or \refrange
  204. % --- construct reference mark in \@refmark
  205.   \make@refmark{#2}%                    % ref mark for 2nd ref
  206.   \xdef\@refmarktwo{\@refmark}%         % save for later
  207.   \make@refmark{#1}%                    % ref mark for 1st ref
  208.   \xdef\@refmark{\@refmark--\@refmarktwo}% create range of references
  209. %
  210.   \add@refmark                          % add to \@refmarklist
  211.   \flush@reflist{#3}%                   % flush output list
  212.   #3}%                                  % do the remaining #3 args
  213.  
  214. %======================================================================*
  215. \ATlock         % make @ not a letter (hides internal macros).
  216.  
  217. \emsg{Patched to Version \fmtversion, \revdate.}%
  218.  
  219. %>>> EOF TXSpatch.tex
  220.